import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-default/index.css'; // 默认主题
//import '../static/css/theme-green/index.css';       // 浅绿色主题
import "babel-polyfill";

Vue.use(ElementUI);
Vue.prototype.$axios = axios;
Vue.prototype.request_header = {
	'Content-Type': 'application/json;charset=utf-8',
	'Accept': 'application/json',
};

router.beforeEach((to, from, next) => {
    if (!localStorage.token && to.matched.some(record => record.meta.requiresAuth)) {
        next({
            path: '/login',
            query: { redirect: to.fullPath }
        })
    } else {
        next() // 确保一定要调用 next()
    }
});

Vue.prototype.request_url = "http://api.xiaoweixitong.com/";
Vue.prototype.file_url = "http://file.xiaoweixitong.com/";
// Vue.prototype.request_url = "http://localhost/proxy/public/index.php/";
new Vue({
	router,
	render: h => h(App)
}).$mount('#app');
